package com.xbai.springcloud.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author xbai
 * @Date 2021/6/3
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/consumer")
public class OrderNacosController {

    private static final String SERVER_URL = "http://nacos-payment-provider";

    private final RestTemplate restTemplate;

    @GetMapping("/nacos/{id}")
    public String getPayment(@PathVariable("id") Integer id) {
        return restTemplate.getForObject(SERVER_URL + "/payment/nacos/" + id, String.class);
    }
}
